package com.demo2do.fms.entity.appraisal;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.Alias;

/**
 *
 * @author Ark
 *
 */
@Alias("AppraisalTarget")
public enum AppraisalTarget {
    
    TRANS("trans", "motor", "运输"),
    
    WAVE("wave", "storage", "仓储"),
    
    VENDOR("vendor", "vendor", "一般供方");
    
    private String alias;
    
    private String name;
    
    private String description;
    
    /**
     * 
     * @param alias
     * @param description
     */
    AppraisalTarget(String alias, String name, String description) {
        this.alias = alias;
        this.name = name;
        this.description = description;
    }
    
    /**
     * 
     * @param alias
     * @return
     */
    public static AppraisalTarget aliasOf(String alias){
        for(AppraisalTarget appraisalTarget : AppraisalTarget.values()){
            if(appraisalTarget.getAlias().equals(alias)){
                return appraisalTarget;
            }
        }
        return null;
    }
    
    /**
     * @param description
     * @return
     */
    public static AppraisalTarget descriptionOf(String description) {
        for (AppraisalTarget appraisalTarget : AppraisalTarget.values()) {
            if (StringUtils.equals(description, appraisalTarget.getDescription())) {
                return appraisalTarget;
            }
        }
        return null;
    }
    
    /**
     * @return
     */
    public boolean isVendor() {
        return this.equals(VENDOR);
    }
    
    /**
     * 
     * @return
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * 
     * @return
     */
    public String getName() {
        return name;
    }
    
    /**
     * 
     * @return
     */
    public String getDescription() {
        return description;
    }
}
